import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  // override config from framework / plugin
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1615450552746_7709';

  // add your egg config in here
  config.middleware = [ 'request', 'notfoundHandler' ];
  exports.static = true;
  config.view = {
    defaultViewEngine: 'nunjucks',
  };
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    database: 'frbbs',
  };
  config.jwt = {
    secret: '123456',	// 自定义token的加密条件字符串，可按各自的需求填写
  };
  config.security = {
    csrf: {
      enable: false,
    },
  };
  config.validate = {
    // convert: false,
    // validateRoot: false,
  };
  config.redis = {
    client: {
      port: 6379, // Redis port
      host: '127.0.0.1', // Redis host
      password: '',
      db: 0,
    },
  };
  config.request = {
    match: '/api',
  };

  // add your special config in here
  const bizConfig = {
    sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
  };

  // the return config will combines to EggAppConfig
  return {
    ...config,
    ...bizConfig,
  };
};
